package com.lbn.monitor.app.account;

import com.free.framework.business.NetSubscriber;
import com.lbn.monitor.api.AppHost;
import com.lbn.monitor.api.model.CheckUpdate;
import com.lbn.monitor.base.AppBasePresenter;

import java.util.List;

/**
 * Created by 李炳南
 * 2017/3/5.
 */

public class AccountPresenter extends AppBasePresenter<IAccountView> {

    public void checkUpdate(final int code){

        subscribeNetwork(AppHost.getApi().checkUpdate(), new NetSubscriber<List<CheckUpdate>>(getView(),false) {
            @Override
            public void onNext(List<CheckUpdate> o) {
                CheckUpdate data =  o.get(0);
                if(data.getVersionCode()>code){
                    getView().newVersion(o.get(0).getAppUrl());
                }
            }
        });
    }
}
